package com.wuxiaofan.api;

import com.wuxiaofan.entity.model.DepartmentMongo;
import com.wuxiaofan.service.DepartmentService;
import com.wuxiaofan.vo.ReturnResult;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wuxiaofan
 * @date 2021/11/2 8:54 上午
 */
@RestController
@RequestMapping("department")
public class DepartmentApi {

    @Resource
    private DepartmentService departmentService;

    @ApiOperation(value = "上传科室")
    @PostMapping("saveDepartment")
    public ReturnResult saveDepartment(@RequestBody DepartmentMongo departmentMongo){
        departmentService.save(departmentMongo);
        return ReturnResult.success("保存科室成功");
    }

    @ApiOperation(value = "批量上传科室")
    @PostMapping("batchSaveDepartment")
    public ReturnResult batchSaveDepartment(@RequestBody List<DepartmentMongo> departmentMongos){
        departmentService.batchSave(departmentMongos);
        return ReturnResult.success("批量保存科室成功");
    }

    @ApiOperation(value = "查询医院所有科室列表")
    @GetMapping("getDeptList/{hoscode}")
    public ReturnResult getDeptList(@PathVariable String hoscode) {
        List<DepartmentMongo> departmentMongoList = departmentService.all(hoscode);
        return ReturnResult.success("查询医院所有科室列表",departmentMongoList);
    }

    @ApiOperation(value = "获取分页列表")
    @PostMapping("department/list")
    public ReturnResult list(){
        return ReturnResult.success("分页查询成功");
    }

    @ApiOperation(value = "删除科室")
    @GetMapping("department/remove/{id}")
    public ReturnResult remove(@PathVariable("id") String id){
        departmentService.deleteById(id);
        return ReturnResult.success("删除科室成功");
    }
}
